﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.FireProjects.BLL;
using Yipusoft.FireProjects.Model;
using Yipusoft.Common.BLL;

public partial class BasicBase_Drilling_DrillingView : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            init();
        }
    }

    void init()
    {
        if (!Yipusoft.Account.BLL.User.HasPermission(User.Identity.Name, "201312") && !Yipusoft.Account.BLL.User.HasPermission(User.Identity.Name, "201316"))
        {
            Response.Write("<script>alert('没有权限！');history.back(0);</script>");
            return;
        }
        DrillingNoteInfo Note = DrillingNote.GetDetail(new Guid(Request.QueryString["id"]));
        Department.Text = Yipusoft.Account.BLL.Department.GetDepartment(Note.DepartmentId).FullName;
        Part.Text = Note.Part;
        CircsSeting.Text = Note.CircsSeting;
        Wind.Text = Note.Wind;
        Effect.Text = Note.Effect;
        this.Note.Text = Note.Note;
        this.DateDrilling.Text = Note.DateDrilling.ToLongDateString();
        this.SetAd.Text = Note.SetAd;
        this.Compare.Text = Note.Compare;
        Principal.Text = Note.Principal;
        TimeLastModified.Text = Note.TimeLastModified.ToString();
        Place.Text = Note.Place;
        //参照预案
        BindProject(Note.FireProjectID.ToString());
        //参加单位
        string NoteID = Request.QueryString["id"];
        string where = " NoteId='" + NoteID + "'";
        UserGrid.DataSource = DrillingDepartment.GetList(where + "  and IsActive=1 ");
        UserGrid.DataBind();
        GridView1.DataSource = DrillingDepartment.GetList(where + "  and IsActive=0 ");
        GridView1.DataBind();
    }
    private void BindProject(string ID)
    {

        FireProjectInfo info = FireProject.getFireproject(new Guid(ID));
	if (info == null)
            return;
        if (info.ClassID.Length > 0)
        {
            lblClass.Text = CodeItem.GetCodeItem(info.ClassID).ItemName;
        }
        if (info.TypeID.Length > 0)
        {
            lblType.Text = CodeItem.GetCodeItem(info.TypeID).ItemName;
        }
        lblDepartment.Text = info.DepartmentName;
        lblDescription.Text = UserFun.TextToHtml(info.Description);
        lblProjectName.Text = info.ProjectName;
        lblSetTime.Text = info.SetTime.ToString();
        lblUpdateTime.Text = info.UpdateTime.ToString();
        lblUpdateAD.Text = "";
        lblSetAD.Text = "";
        lbtViewWord.NavigateUrl = "../FireProject/WordFile/" + info.WordName;
    }
    protected void UserGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label lblID = e.Row.FindControl("lblID") as Label;
            lblID.Text = Convert.ToString(e.Row.RowIndex + 1);
            //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色 
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#F5F5F5',this.style.fontWeight='';");
            //当鼠标离开的时候 将背景颜色还原的以前的颜色 
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
        }
    }
}
